{% extends 'generic/object_detail.html' %}
{% load helpers %}
{% load tz %}

{% block content_left_page %}
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Site</strong>
            </div>
            <table class="table table-hover panel-body attr-table">
                <tr>
                    <td>Status</td>
                    <td>
                        <span class="label" style="color: {{ object.status.color|fgcolor }}; background-color: #{{ object.status.color }}">{{ object.get_status_display }}</span>
                    </td>
                </tr>
                <tr>
                    <td>Region</td>
                    <td>
                        {% if object.region %}
                            {% for region in object.region.get_ancestors %}
                                <a href="{{ region.get_absolute_url }}">{{ region }}</a> /
                            {% endfor %}
                            <a href="{{ object.region.get_absolute_url }}">{{ object.region }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Tenant</td>
                    <td>
                        {% if object.tenant %}
                            {% if object.tenant.group %}
                                <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
                            {% endif %}
                            <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Facility</td>
                    <td>{{ object.facility|placeholder }}</td>
                </tr>
                <tr>
                    <td>AS Number</td>
                    <td>{{ object.asn|placeholder }}</td>
                </tr>
                <tr>
                    <td>Time Zone</td>
                    <td>
                        {% if object.time_zone %}
                            {{ object.time_zone }} (UTC {{ object.time_zone|tzoffset }})<br />
                            <small class="text-muted">Site time: {% timezone object.time_zone %}{% now "SHORT_DATETIME_FORMAT" %}{% endtimezone %}</small>
                        {% else %}
                            <span class="text-muted">&mdash;</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Description</td>
                    <td>{{ object.description|placeholder }}</td>
                </tr>
            </table>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Contact Info</strong>
            </div>
            <table class="table table-hover panel-body attr-table">
                <tr>
                    <td>Physical Address</td>
                    <td>
                        {% if object.physical_address %}
                            <div class="pull-right noprint">
                                <a href="https://maps.google.com/?q={{ object.physical_address|urlencode }}" target="_blank" class="btn btn-primary btn-xs">
                                    <i class="mdi mdi-map-marker"></i> Map it
                                </a>
                            </div>
                            <span>{{ object.physical_address|linebreaksbr }}</span>
                        {% else %}
                            <span class="text-muted">&mdash;</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Shipping Address</td>
                    <td>{{ object.shipping_address|linebreaksbr|placeholder }}</td>
                </tr>
                <tr>
                    <td>GPS Coordinates</td>
                    <td>
                        {% if object.latitude and object.longitude %}
                            <div class="pull-right noprint">
                                <a href="https://maps.google.com/?q={{ object.latitude }},{{ object.longitude }}" target="_blank" class="btn btn-primary btn-xs">
                                    <i class="mdi mdi-map-marker"></i> Map it
                                </a>
                            </div>
                            <span>{{ object.latitude }}, {{ object.longitude }}</span>
                        {% else %}
                            <span class="text-muted">&mdash;</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Contact Name</td>
                    <td>{{ object.contact_name|placeholder }}</td>
                </tr>
                <tr>
                    <td>Contact Phone</td>
                    <td>
                        {% if object.contact_phone %}
                            <a href="tel:{{ object.contact_phone }}">{{ object.contact_phone }}</a>
                        {% else %}
                            <span class="text-muted">&mdash;</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Contact E-Mail</td>
                    <td>
                        {% if object.contact_email %}
                            <a href="mailto:{{ object.contact_email }}">{{ object.contact_email }}</a>
                        {% else %}
                            <span class="text-muted">&mdash;</span>
                        {% endif %}
                    </td>
                </tr>
            </table>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Comments</strong>
            </div>
            <div class="panel-body rendered-markdown">
                {% if object.comments %}
                    {{ object.comments|render_markdown }}
                {% else %}
                    <span class="text-muted">None</span>
                {% endif %}
            </div>
        </div>
{% endblock content_left_page %}

{% block content_right_page %}
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Stats</strong>
            </div>
            <div class="row panel-body">
                <div class="col-md-4 text-center">
                    <h2><a href="{% url 'dcim:rack_list' %}?site={{ object.slug }}" class="btn {% if stats.rack_count %}btn-primary{% else %}btn-default{% endif %} btn-lg">{{ stats.rack_count }}</a></h2>
                    <p>Racks</p>
                </div>
                <div class="col-md-4 text-center">
                    <h2><a href="{% url 'dcim:device_list' %}?site={{ object.slug }}" class="btn {% if stats.device_count %}btn-primary{% else %}btn-default{% endif %} btn-lg">{{ stats.device_count }}</a></h2>
                    <p>Devices</p>
                </div>
                <div class="col-md-4 text-center">
                    <h2><a href="{% url 'ipam:prefix_list' %}?site={{ object.slug }}" class="btn {% if stats.prefix_count %}btn-primary{% else %}btn-default{% endif %} btn-lg">{{ stats.prefix_count }}</a></h2>
                    <p>Prefixes</p>
                </div>
                <div class="col-md-4 text-center">
                    <h2><a href="{% url 'ipam:vlan_list' %}?site={{ object.slug }}" class="btn {% if stats.vlan_count %}btn-primary{% else %}btn-default{% endif %} btn-lg">{{ stats.vlan_count }}</a></h2>
                    <p>VLANs</p>
                </div>
                <div class="col-md-4 text-center">
                    <h2><a href="{% url 'circuits:circuit_list' %}?site={{ object.slug }}" class="btn {% if stats.circuit_count %}btn-primary{% else %}btn-default{% endif %} btn-lg">{{ stats.circuit_count }}</a></h2>
                    <p>Circuits</p>
                </div>
                <div class="col-md-4 text-center">
                    <h2><a href="{% url 'virtualization:virtualmachine_list' %}?site={{ object.slug }}" class="btn {% if stats.vm_count %}btn-primary{% else %}btn-default{% endif %} btn-lg">{{ stats.vm_count }}</a></h2>
                    <p>Virtual Machines</p>
                </div>
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Rack Groups</strong>
            </div>
            <table class="table table-hover panel-body">
                {% for rg in rack_groups %}
                    <tr>
                        <td style="padding-left: {{ rg.level }}8px"><i class="mdi mdi-folder-open"></i> <a href="{{ rg.get_absolute_url }}">{{ rg }}</a></td>
                        <td>{{ rg.rack_count }}</td>
                        <td class="text-right noprint">
                            <a href="{% url 'dcim:rack_elevation_list' %}?group_id={{ rg.pk }}" class="btn btn-xs btn-primary" title="View elevations">
                                <i class="mdi mdi-server"></i>
                            </a>
                        </td>
                    </tr>
                {% endfor %}
                <tr>
                    <td><i class="mdi mdi-folder-open"></i> All racks</td>
                    <td>{{ stats.rack_count }}</td>
                    <td class="text-right noprint">
                        <a href="{% url 'dcim:rack_elevation_list' %}?site={{ object.slug }}" class="btn btn-xs btn-primary" title="View elevations">
                            <i class="mdi mdi-server"></i>
                        </a>
                    </td>
                </tr>
            </table>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Images</strong>
            </div>
            {% include 'inc/image_attachments.html' with images=object.images.all %}
            {% if perms.extras.add_imageattachment %}
                <div class="panel-footer text-right noprint">
                    <a href="{% url 'dcim:site_add_image' object_id=object.pk %}" class="btn btn-primary btn-xs">
                        <span class="mdi mdi-plus-thick" aria-hidden="true"></span>
                        Attach an image
                    </a>
                </div>
            {% endif %}
        </div>
{% endblock content_right_page%}
